<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let str = '李四爱打官司'
        // 替换字符串   replace
        // replace('旧的值','新的值')
        console.log(str.replace('打官司','吃鱼'));


        // 重复字符串/字符串克隆
        // .repeat(重复次数)
        console.log(str.repeat(2));
        // 字符串补齐
        let num = '1'
        // .padStart(位数,补位参数)   向前补齐
        console.log(num.padStart(2,'0'));
        console.log(num.padEnd(3,'x'));
        
        // 案例:时间补齐  2025.1.1.1.1.1    2025.01.01.01.01.01
        let date = '2025.1.1.1.1.1'
        let strarr = date.split('.')
        console.log(strarr);
     for (let i = 0; i < strarr.length; i++) {
        strarr[i] = strarr[i].padStart(2,'0')
        
     }
    //  将数组转化成字符串
        console.log(strarr.join('.'));
        

        


    </script>
</body>
</html>